#include "qmlwindow.h"
#include <QtGui/QApplication>

QmlWindow::QmlWindow(QWidget *parent) :
    QDeclarativeView(parent)
{
    this->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    //this->setGeometry(50,50,1024,600);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setStyleSheet("background:transparent;");

    //this->setWindowFlags(Qt::FramelessWindowHint);

    this->hide();

}



void QmlWindow::keyPressEvent ( QKeyEvent * event ){
    //qDebug()<<"top Key event:"<< event->text()<<" key:"<<event->key();
    emit(qmlViewKeyPressed(event->key()));
    this->QDeclarativeView::keyPressEvent(event);
}

void QmlWindow::focusInEvent(QFocusEvent *e){
    //qDebug()<<"top focusInEvent";
    this->QDeclarativeView::focusInEvent(e);

}

void QmlWindow::focusOutEvent(QFocusEvent *e){
    //qDebug()<<"top focusOutEvent";
    this->QDeclarativeView::focusOutEvent(e);
    emit(focusOutEventSglRedirect());
}
void QmlWindow::hideEvent(QHideEvent *e){
    //qDebug()<<"top hideEvent";
    emit(hideEventSglRedirect());
}

void QmlWindow::showEvent ( QShowEvent * e){
    //qDebug()<<"top showEvent";
    this->QDeclarativeView::showEvent(e);
    emit(showEventSglRedirect());
}

void QmlWindow::resizeEvent( QResizeEvent * e){
    this->QDeclarativeView::resizeEvent(e);
    emit(resizeEventSglRedirect());
}

void QmlWindow::moveEvent( QMoveEvent *e){
    this->QDeclarativeView::moveEvent(e);
    emit(moveEventSglRedirect());
}

void QmlWindow::onExternKeyPressEvent(QKeyEvent * e){
    if(this->isHidden()){
        qDebug()<<"hidden stop top key press propagation";
        return;
    }
    qDebug()<<"propagation";
    this->keyPressEvent(e);
}













//this->setWindowModality(Qt::ApplicationModal);

//this->setWindowFlags(Qt::X11BypassWindowManagerHint);






//qmlViewer->setWindowFlags(Qt::BypassGraphicsProxyWidget);
//qmlViewer->setWindowFlags(Qt::WindowStaysOnTopHint);
//qmlViewer->setWindowFlags(Qt::X11BypassWindowManagerHint);
//qmlViewer->setWindowFlags(Qt::SplashScreen);
//qmlViewer->setWindowFlags(Qt::Popup);


//Qt::X11BypassWindowManagerHint

/*qDebug()<<"connection signal metier";
//QObject *item = ;
/*connect(qmlViewer->rootObject(), SIGNAL(responseDbus(QString,QString))
                 ,this, SLOT(responseSlot(QString,QString)));
qDebug()<<"connection signal metier OK";*/

